set nu
set ts=4
set sw=4
set cindent
set textwidth=80
set comments=sl:/*,mb:**,elx:*
filetype plugin indent  on
set completeopt=longest,menu
set autoindent
set encoding=utf-8 fileencodings=ucs-bom,utf-8,cp936
set fdm=manual "indent
set hlsearch
set tags+=~/.vim/systags
" Always show the status line
set laststatus=2
" Status line format:
" {buffer number}: {file name, relative path to the current working directory}{modified flag}{readonly flag}
" {help flag}{preview flag} [file type, encoding, format] [current line-total lines, current column][position percentage in file]
set statusline=%n:\ %f%m%r%h%w\ [%Y,%{&fileencoding},%{&fileformat}]\ [%l-%L,%v][%p%%]
" change commennt color to baby blue
hi Comment ctermfg=6
let mapleader = ","
noremap <C-h> :set nonu<CR>
noremap <C-j> :set nu<CR>
" Ctrl+m is the hot key of 'Enter' key in linux terminal,
" so map it also will map 'Enter' key.
"noremap <C-m> :make<CR>
noremap <C-k> :make<CR>
noremap <F7> :make clean;make<CR> 

"======================================
"project manager
"======================================
noremap <silent> <Leader>pj :!~/opt/scripts/project<CR>
if filereadable("./cscope.files")
	"silent exec '!ls'
	"exec '!project'
	silent exec '!~/opt/scripts/project'
endif

"=================
"taglist option
"=================
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
let Tlist_Use_Right_Window=0
"noremap <silent> <F6> :TlistToggle<CR>
noremap <silent> <Leader>tt :TlistToggle<CR>

"=====================
"BufExplore setting
"=====================
let g:BufExplorerShowRelativePath=0
let g:BufExplorerSplitRight=0
let g:BufExplorerSplitVertical=1
let g:BufExplorerSplitBelow=0
noremap <silent> <Leader>be :BufExplorer<CR>
noremap <silent> <Leader>bs :BufExplorerHorizontalSplit<CR>
noremap <silent> <Leader>bv :BufExplorerVerticalSplit<CR>

"========================================
"csope settings
"========================================
if has("cscope")
	set csprg=/usr/local/bin/cscope
	set csto=0
	set cst
	set nocsverb
	" add any database in current directory
	if filereadable("cscope.out")
		cs add cscope.out
	" else add database pointed to by environment
	elseif $CSCOPE_DB != ""
		cs add $CSCOPE_DB
	endif
	set csverb
endif
nmap <C-_>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-_>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>	
nmap <C-_>d :cs find d <C-R>=expand("<cword>")<CR><CR> 

"=========================================
"NERDTree settings
"=========================================
noremap  <Leader>nt :NERDTree


""""""""""""""""""""""""""""""
" lookupfile setting
""""""""""""""""""""""""""""""""
 let g:LookupFile_MinPatLength = 2               "最少输入2个字符才开始查找
 let g:LookupFile_PreserveLastPattern = 0        "不保存上次查找的字符串
 let g:LookupFile_PreservePatternHistory = 1     "保存查找历史
 let g:LookupFile_AlwaysAcceptFirst = 1          "回车打开第一个匹配项目
 let g:LookupFile_AllowNewFiles = 0              "不允许创建不存在的文件
 if filereadable("./lookup.files")                "设置tag文件的名字
 	let g:LookupFile_TagExpr = '"./lookup.files"'
 endif

 nmap <silent> <Leader>lf <Plug>LookupFile<CR>
 nnoremap <silent> <Leader>lb :LUBufs<CR>
 nnoremap <silent> <Leader>lw :LUWalk<CR>
 nnoremap <silent> <Leader>lt :LUTags<CR>

"======================================
"quickfix setting
"======================================
noremap <silent> <Leader>cn :cn<CR>
noremap <silent> <Leader>cp :cp<CR>
noremap <silent> <Leader>cw :cw<CR>
noremap <silent> <Leader>cc :cc<CR>
noremap <silent> <Leader>co :copen<CR>
noremap <silent> <Leader>ce :cclose<CR>

"======================================
"winmanager settings
"======================================
let g:winManagerWindowLayout = 'BufExplorer,TagList,FileExplorer'
let g:winManagerWidth = 30
noremap <F2> :WMToggle<cr>
nmap <silent> <C-w><C-t> :WMToggle<CR>
nmap <silent> <C-w><C-f> :FirstExplorerWindow<CR>
nmap <silent> <C-w><C-b> :BottomExplorerWindow<CR>

